﻿using PreGUI.Attributes;
using PreGUI.Widgets;
using System;
using UnityEngine;

[WindowResource("HelloWindow")]
public class TestViewModel
{
    [BindControl("edtTest")]
    public PGTextEdit TestEditor { get; set; }

    [BindControl("btnCancel")]
    public PGButton CancelButton { get; set; }

    [ControlValueTarget("edtTest")]
    public string TestTextValue { get; set; }

    [ButtonClickEvent("btnAccept")]
    public void AcceptClicked(PGButton source)
    {
        source.Caption = TestEditor.Text;
        CancelButton.Enabled = !CancelButton.Enabled;
    }

    [ButtonClickEvent("btnCancel")]
    public void CancelClicked(PGButton source)
    {
        TestEditor.Text = "Code Updated!";
        Debug.Log(String.Format("Clicked {0}!", source.Caption));
    }
}

